package com.my.code.map;

import java.util.HashSet;
import java.util.Set;

public class TestMap {
    public static final int MAXIMUM_CAPACITY = 1 << 30;

    private static final int tableSizeFor(int c) {
        int n = c - 1;
        int i;
        i = n >>> 1;
        n |= i;
        i = n >>> 2;
        n |= i;
        i = n >>> 4;
        n |= i;
        i = n >>> 8;
        n |= i;
        i = n >>> 16;
        n |= i;
        return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
    }

    static final int resizeStamp(int n) {
        return Integer.numberOfLeadingZeros(n) | (1 << 15);
    }

    public static void main3(String[] args) {
        int i = resizeStamp(1280);
        System.out.println("i = " + (i<<16));
    }

    public static void main1(String[] args) {
        Set<Integer> set = new HashSet<>();
        int n = 1<<8;
        for (int i = 0; i < 1000000; i++) {
            //set.add(i & (n*2-1));
            set.add(i & n);
        }
        System.out.println(set);
        System.out.println("set.size = " + set.size());
        System.out.println("set.max = " + set.stream().max(Integer::compareTo));

    }

    public static void main(String[] args) {
        //Set<Integer> set = new HashSet<>();
        int n = 1<<4;
        System.out.println(32&n);
        System.out.println(17&n);
        System.out.println(16&n);
        System.out.println(15&n);
        System.out.println(12&n);
        System.out.println(13&n);
    }
}
